﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data;
using System.Data.SqlClient;
namespace DAO
{
   public class LoaiKyHanLSDA
    {
       public static LoaiKyHanLS GetByID(int maID)
       {
           LoaiKyHanLS loai = null;
           SqlConnection cn = DataProvider.Connect();
           SqlCommand cmd = new SqlCommand("Proc_LoaiKyHanLS_GetById", cn);
           cmd.CommandType = CommandType.StoredProcedure;
           cmd.Parameters.Add(new SqlParameter("@maLoaiKHLS", maID));
           SqlDataReader dataReader = cmd.ExecuteReader();
           if (dataReader.Read())
           {
               loai = new LoaiKyHanLS();
               loai.MaLoaiKHLS = maID;
               loai.TenLoai = Convert.ToString(dataReader["TenLoai"]);
               loai.DelFlg = Convert.ToInt32(dataReader["DelFlg"]);
               loai.LastUpdate = Convert.ToDateTime(dataReader["LastUpdate"]);
           }
           cn.Close();
           return loai;
       }
       public static DataTable DSKyHan()
       {
           DataTable dt = new DataTable();
           SqlConnection cn = DataProvider.Connect();
           SqlCommand cmd = new SqlCommand("Proc_KyHan_All", cn);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           da.Fill(dt);
           cn.Close();
           return dt;
       }
    }
}
